package younian.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

/**
 * 主題信息类
 * 
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_section")
public class Section {

	private int id;
	private String name;// 主题名称
	private User master;// 所属用户
	private String logo;// 主题logo
	private Zone zone;// 所属版块
	private List<Topic> topicList = new ArrayList<Topic>();// 主题内所有帖子

	@Id
	@GeneratedValue(generator = "_native")
	@GenericGenerator(name = "_native", strategy = "native")
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(length = 50)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToOne
	@JoinColumn(name = "masterId", nullable = true)
	public User getMaster() {
		return master;
	}

	public void setMaster(User master) {
		this.master = master;
	}

	@OneToMany(mappedBy = "section", fetch = FetchType.EAGER)
	public List<Topic> getTopicList() {
		return topicList;
	}

	public void setTopicList(List<Topic> topicList) {
		this.topicList = topicList;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "zoneId")
	public Zone getZone() {
		return zone;
	}

	public void setZone(Zone zone) {
		this.zone = zone;
	}

	public String getLogo() {
		return logo;
	}

	public void setLogo(String logo) {
		this.logo = logo;
	}

	@Override
	public String toString() {
		return "Section [id=" + id + ", name=" + name + ", master=" + master + ", logo=" + logo + ", topicList="
				+ topicList + ", zone=" + zone + "]";
	}

}
